package com.vue.cn.common.http;

import java.util.HashMap;

public class AjaxResult extends HashMap<String,Object> {

    public static final String STATUS = "status";
    public static final String MESSAGE = "message";
    public static final String DATA = "data";
    public static final String TOTAL = "total";

    public AjaxResult(){
    }

    public AjaxResult(StatusEnum statusEnum){
        super.put(STATUS,statusEnum.getStatus());
        super.put(MESSAGE,statusEnum.getMessage());

    }

    public static AjaxResult ok(){
        return new AjaxResult(StatusEnum.OK);
    }

    public static AjaxResult error(){
        return new AjaxResult(StatusEnum.ERROR);
    }

    public static AjaxResult ok(StatusEnum statusEnum){
        return new AjaxResult(statusEnum);
    }

    public static AjaxResult error(StatusEnum statusEnum){
        return new AjaxResult(statusEnum);
    }

    public static AjaxResult ok(Object data){
        AjaxResult ok = ok();
        ok.put(DATA,data);
        return ok;
    }

    public static AjaxResult ok(StatusEnum statusEnum,Object data){
        AjaxResult ok = ok(statusEnum);
        ok.put(DATA,data);
        return ok;
    }

    public static AjaxResult ok(Object data,long total){
        AjaxResult ok = ok(StatusEnum.OK);
        ok.put(DATA,data);
        ok.put(TOTAL,total);
        return ok;
    }


}
